<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="/css/webbase.css" />
    <link rel="stylesheet" type="text/css" href="/css/pages-register.css" />
    <script type="text/javascript" src="/js/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/js/plugins/jquery.easing/jquery.easing.min.js"></script>
    <script type="text/javascript" src="/js/plugins/sui/sui.min.js"></script>
    <script type="text/javascript" src="/js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
    <script type="text/javascript" src="/js/pages/register.js"></script>
    <!--bootstrap-toastr-->
    <script type="text/javascript" src="/bootstrap/toastr/toastr.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/bootstrap/toastr/toastr.css">
</head>
<body>
<h1>找回密码</h1>
<form class="sui-form form-horizontal" id="getPassword">
    <div class="control-group">
        <label class="control-label">手机号：</label>
        <div class="controls">
            <input type="text" name="phone" id="phone" placeholder="请输入你注册用的手机号" class="input-xfat input-xlarge">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label"></label>
        <div class="controls btn-reg">
            <a class="sui-btn btn-block btn-xlarge btn-danger" href="javascript:getBackPassword();">找回密码</a>
        </div>
    </div>
</form>
<script>
    function getBackPassword() {
        toastr.success("您的密码正在找回，请稍等");
        $.ajax({
            url : "/user/backPassword",
            type : "post",
            data : {phone : $("#phone").val()},
            dataType : "json",
            success : function (returnData) {
                if (returnData.code == 200) {
                    toastr.success("您的密码已找回，请到邮箱去查看");
                }else if (returnData.code == 40002){
                    toastr.error(returnData.message);
                }else {
                    toastr.error(returnData.message);
                }
                setTimeout(function () {
                    location.href = "/user/toUserLogin";
                }, 1000);
            },
            error : function (returnData) {
                toastr.error("系统错误");
                console.log(returnData);
            }
        })
    }
</script>
</body>
</html>